Fwd: Re: Multiple open ResultSets not allowed?

Поиск
Список
Период
Сортировка
От Jeff Kolesky
Тема Fwd: Re: Multiple open ResultSets not allowed?
Дата
Msg-id a05200f05ba9bbb38ae6e@[192.168.1.9]
обсуждение исходный текст
Ответы Re: Multiple open ResultSets not allowed?
Список pgsql-jdbc
To back up my suspicions, I looked up the JDBC spec
(http://java.sun.com/products/jdbc/download.html#corespec30).  On
page 93 under the heading "13.1.1 Creating Statements" it clearly
states

     Each Connection object can create multiple Statement objects that may be
     used concurrently by the program.

If multiple Statement objects can be created, why would you not be
able to execute multiple queries and therefore access multiple
ResultSets?

Jeff


>X-Original-To: pgsql-jdbc@postgresql.org
>X-Sender: edusoft.com/jeff@fire.he.net
>Date: Mon, 17 Mar 2003 09:01:48 -0800
>To: Barry Lind <blind@xythos.com>
>From: Jeff Kolesky <jeff@edusoft.com>
>Subject: Re: [JDBC] Multiple open ResultSets not allowed?
>Cc: pgsql-jdbc@postgresql.org
>Sender: pgsql-jdbc-owner@postgresql.org
>
>Just to make sure I wasn't looking at the code incorrectly, I wrote
>the following test code, making sure not to close the connection
>before trying to get data from the result set:
>
>     Connection con = DB.getConnection();
>     Statement s1 = con.createStatement();
>     ResultSet rs1 = s1.executeQuery("SELECT * FROM table1");
>     while(rs1.next())
>     {
>         String col = rs1.getString("col");
>         System.out.println(col);
>         Statement s2 = con.createStatement();
>         ResultSet rs2 = s2.executeQuery("SELECT * FROM table2");
>         while(rs2.next())
>         {
>             String col2 = rs2.getString("col");
>             System.out.println("\t" + col2);
>         }
>         rs2.close();
>         s2.close();
>     }
>     rs1.close();
>     s1.close();
>     con.close();
>
>Running this code throws the same exception.  Looks like the
>connection is being closed incorrectly by the driver, or more likely
>that ResultSet data (Vector rows) is being set to null somehow.
>
>Any other ideas?
>
>Thanks.
>
>Jeff
>
>
>At 7:55 PM -0800 3/14/03, Barry Lind wrote:
>>The error message says that the Connection is closed.  You can't
>>use a statement or result set after the connection that owns them
>>is closed. This is part of the jdbc spec, and I think logic in the
>>driver was tightened up in this area in 7.3.
>>
>>thanks,
>>--Barry
>>
>>
>>Jeff Kolesky wrote:
>>>I have just switched to using the 7.3 JDBC driver and am no longer
>>>allowed to have multiple ResultSets open at the same time.
>>>
>>>When running code that iterates through two open ResultSets (from
>>>two different Statements from the same Connection), the following
>>>exception is thrown:
>>>
>>>     Connection is closed. Operation is not permitted.
>>>         at org.postgresql.jdbc1.AbstractJdbc1ResultSet.next
>>>(AbstractJdbc1ResultSet.java:92)
>>>
>>>I haven't looked at the AbstractJdbc1ResultSet code to see what is
>>>going on, but according to the JDBC Javadocs, "if the reading of
>>>one ResultSet object is interleaved with the reading of another,
>>>each must have been generated by different Statement objects."
>>>Therefore, the code I am executing should not throw this
>>>exception, and with the previous version of the driver it did not.
>>>
>>>Is this a known bug?  Has it been fixed?  Did I misinterpret the Javadocs?
>>>
>>>Thanks.
>>>
>>>Jeff
>>>
>>>---------------------------(end of broadcast)---------------------------
>>>TIP 6: Have you searched our list archives?
>>>
>>>http://archives.postgresql.org
>>>
>>
>>
>>
>>
>>---------------------------(end of broadcast)---------------------------
>>TIP 2: you can get off all lists at once with the unregister command
>>    (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 4: Don't 'kill -9' the postmaster


В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Rich Cullingford
Дата:
Сообщение: Re: Multiple open ResultSets not allowed?
Следующее
От: Richard Welty
Дата:
Сообщение: Re: Multiple open ResultSets not allowed?